//
//  DFUserSuggestController.m
//  DFront
//
//  Created by lanou on 15/11/3.
//  Copyright © 2015年 xuzenghui. All rights reserved.
//

#import "DFUserSuggestController.h"

@interface DFUserSuggestController()

@property (nonatomic,strong)UITextView *suggestView;
@property (nonatomic,strong)UIButton *giveBtn;

@end

@implementation DFUserSuggestController

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    _suggestView = [[UITextView alloc]initWithFrame:CGRectMake(10, 84, kScreenWidth - 20, kScreenHeight / 3)];
    
    _suggestView.layer.borderColor = [UIColor grayColor].CGColor;
    _suggestView.layer.borderWidth = 1.0;
    _suggestView.layer.cornerRadius = 5;
    _suggestView.textContainerInset = UIEdgeInsetsMake(0, 10, 10, 10);
    
    [self.view addSubview:_suggestView];

    [self.view addSubview:self.topView];
    [self.topView addSubview:self.backBtn];
//  提交按钮
    _giveBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _giveBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    _giveBtn.frame = CGRectMake(kScreenWidth - 80, 7, 80, 30);
    [_giveBtn addTarget:self action:@selector(submmit) forControlEvents:UIControlEventTouchUpInside];
    [_giveBtn setTitle:@"提交" forState:UIControlStateNormal];
    [self.topView addSubview:_giveBtn];
}


- (void)submmit
{
    if (_suggestView.text.length > 0) {

        UIAlertController *alertC = [UIAlertController alertControllerWithTitle:@"提示" message:@"感谢您的意见或建议" preferredStyle:UIAlertControllerStyleAlert];
    [self presentViewController:alertC animated:YES completion:^{
        [alertC dismissViewControllerAnimated:YES completion:nil];
    }];
    [NSTimer scheduledTimerWithTimeInterval:1.5 target:self selector:@selector(backToFront) userInfo:nil repeats:NO];
    }else
    {
        UIAlertController *alertC = [UIAlertController alertControllerWithTitle:@"提示" message:@"内容为空" preferredStyle:UIAlertControllerStyleAlert];
        [self presentViewController:alertC animated:YES completion:^{
            [alertC dismissViewControllerAnimated:YES completion:nil];
        }];
    }
}
- (void)backToFront
{
    [self.navigationController popViewControllerAnimated:NO];
}

@end
